﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;

namespace Lilium.RetailAudit.Data
{
	public class EntityCollection<TEntity> : Collection<TEntity>, ICloneable<EntityCollection<TEntity>>
		where TEntity : ICloneable<TEntity>
	{
		public void AddRange(IEnumerable<TEntity> source)
		{
			if (source == null) throw new ArgumentNullException("source");

			foreach (var item in source)
				Add(item);
		}

		#region ICloneable<EntityCollection<TEntity>> Members

		public EntityCollection<TEntity> Clone()
		{
			var clone = new EntityCollection<TEntity>();
			foreach (var entity in this)
				clone.Add(entity.Clone());
			return clone;
		}

		#endregion

		#region ICloneable Members

		object ICloneable.Clone()
		{
			return Clone();
		}

		#endregion
	}
}
